
<%@page import="model.Operateur"%>
<%@page import="model.Descriptionarret"%>
<%@page import="model.Categoriearret"%>
<%@page import="web.Operation"%>
<%@page import="web.UhtBeans"%>
<%@page import="model.Ligne"%>
<%@page import="java.text.DateFormat"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Date"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.Iterator"%>

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html >

<head >
        
     
  <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
          <meta name="author" content="MWH Team 2" />

       <script type="text/javascript" src="fichier/jquery-1.10.2.js"></script>
       <script type="text/javascript" src="jquery-ui-1.11.0/jquery-ui.js"></script>
       <script type="text/javascript" src="fichier/ajax_js.js"></script>
       <script type="text/javascript" src="fichier/calendrier.js"></script>
       <link rel="stylesheet" media="screen" type="text/css" title="Design" href="fichier/design.css" />    
          <link href="./fichier/bootstrap.min.css" rel="stylesheet">
          <link href="./fichier/Site.css" rel="stylesheet">
          <link rel="stylesheet" href="jquery-ui-1.11.0/jquery-ui.css">
     
         <title>UHT</title>
         
         <script language="javascript">
            function showList() {

                var select = document.getElementById('liste');

                if(select.value == "l1") {
                    document.getElementById('l1').setAttribute('style','visibility:inline');
                } else if(select.value == "l2") {
                    document.getElementById('l2').setAttribute('style','visibility:inline');
                } else {
                    document.getElementById('l3').setAttribute('style','visibility:inline');
                }
            }

       </script>
       
</head>

<body  >
<script language="JavaScript" type="text/javascript">

function getsupport ( )
{
  
  document.SupportForm.submit() ;
}

</script> 

 <% 
       Operateur p = new Operateur();
       String  info="";
       String  info1="";
       String info2="";
  
       
       if (session.getAttribute("oppp")==null){%>
    	<SCRIPT LANGUAGE='JavaScript'>
        window.alert('Veuillez vous identifier');
        window.location.href='Connexion.jsp';
        </SCRIPT>
 <%    } else { 
     	p = (Operateur) session.getAttribute("oppp");
     	 if (p.getIsadmin().equals("false"))
     	 {
     		 info = p.getNomoperateur(); 
     		 info2="Operateur";
     		 info1="opera";
     	 }
     	 else
     	 {
    	    
     		info = p.getNomoperateur(); 
     		info2="Administrateur";
     		info1="admin";
     	 }
 }
    %>
    
   <script language="JavaScript" type="text/javascript">

function getsupport ( )
{
  
  document.SupportForm.submit() ;
}

</script> 


    <div  style="padding-bottom:30px; margin-top:-10px; background-color: green; background-image: url('./fichier/occpp.png'); 
   
    -webkit-background-size: cover;
     -moz-background-size: cover;
     -o-background-size: cover;
      background-size: cover;
       

   "  >
 		<div> <label  style="margin-left:1150px; margin-top:30px; margin-right: 2px; color:#ffffff; font-family: Calibri, sans-serif; "><%=info %><br/><%=info2 %></label></div>

        <p   style="color:#ffffff; font-size:36px;  font-family: Coolvetica Rg;"  align="center">Cute Process UHT</p>
   </div>
<div class="row-offcanvas row-offcanvas-left">
<div id="sidebar" class="sidebar-offcanvas" style="margin-top:18px; ">
<form name="SupportForm" method="post" action="controle">
                         <input type="hidden" name="Adminpanel4" />
                <ul class="nav nav-pills nav-stacked">
                 
                     <li><a href="#">Acceuil</a></li>
                    <li class="active"><a href="Index.jsp">Saisie des Données</a></li>
                    <li class="active"><a href="Resultats.jsp">Resultats</a></li>
                    <li id="Adminpanel" ><a href="Ligne.jsp">Gestion des Lignes</a></li>
                    <li id="Adminpanel1"><a href="Categorie.jsp">Gestion des Categories</a></li>
                    <li id="Adminpanel2"><a href="Arret.jsp">Gestion des Arrêts</a></li>
                    <li id="Adminpanel3"><a href="Operateur.jsp">Gestion des Operateurs</a></li>
                    <li><a href="javascript:getsupport()">Deconnexion</a></li>
        
                     
                </ul>
</form>
        </div>
<button class="sidebar-trigger" data-toggle="offcanvas" style="margin-top:18px;"></button>
        <div id="main">

            

            <div class=" container-fluid body-content "  style="margin-top:10px; ">

         
        


 
   
    <h2 class="button green center" align="center">Saisie des données</h2>
    <br><br>         

 <div align="center" >
 <input type="submit" name="Ajouter" id="Ajouter" value="Ajouter"/> 
 <input type="submit" name="Modifier" id="Modifier" value="Modifier " />
 <input type="submit" name="Supprimer" id="Supprimer" value="Supprimer"/>
 <input type="submit" name="Rechercher" id="Rechercher" value="Rechercher"/>
  <input type="hidden" name="Retourner" id="Retourner" value="Retourner"/>
 <input type="submit" name="Vider" id="Vider" value="Vider"/>

 </div>
 <%
 UhtBeans uhtBs;
 Operation opp = new Operation();
 uhtBs = new UhtBeans();
 uhtBs.setListeLi(opp.allLigne());
 uhtBs.setListeCat(opp.allCategorie());
 uhtBs.setListeArr(opp.allArret());
 %>
 
<table border="1" width="100%">
	<tr align="center">
		<td colspan="4">Ligne<select id="InputLigne" class="form-control"> 
     		<%

			Iterator<Ligne> listLi = uhtBs.getListeLi().iterator();
		        while(listLi.hasNext()){
		        	Ligne Li =listLi.next();
		        	
			%>
                	  <Option  id="NomLigne"><%=Li.getNomligne()%></option>  
			<% } %>
			</select>
		</td>
		</tr>
		<tr align="center">
		<td width="10%" bgcolor=cyan>Catégorie</td>
		<td width="40%">
			<select id="InputNomCat" class="form-control"> 
     <%

			Iterator<Categoriearret> listCat = uhtBs.getListeCat().iterator();
		        while(listCat.hasNext()){
		        	Categoriearret cat =listCat.next();
	 	
			%>
                	  <Option  id="NomCat" value="<%=cat.getIdfam()%>"><%=cat.getNomcat()%></option> 
                	   
                      <% } %>
                      <%Categoriearret cat = new Categoriearret();
                      request.setAttribute("idSS", cat.getIdfam()); %>
                      </select>
		</td>
		<td width="10%" bgcolor=cyan>Arrêts</td>
		<td >
			<select   id="InputArrets" class="form-control" style=""> 
     <%
			Iterator<Descriptionarret> listArr = uhtBs.getListeArr().iterator();
		        while(listArr.hasNext()){
		        	Descriptionarret arr =listArr.next();
	 	
			%>
                	  <Option  id="NomArr" value="<%=arr.getIdarret()%>"><%=arr.getNomarret()%></option>  
                      <% } %>
                      </select>

		</td>
	</tr>
	<tr align="center">
		<td bgcolor=cyan>Date & Heure</td>
		<td>
			<input type="text" name="date" id="InputDate" class="form-control" placeholder="Date & Heure">
		</td>
		<td bgcolor=cyan>Durée</td>
		<td>
			<input type="text" name="dure" id="InputDuree" class="form-control" placeholder="Durée">
		</td>
		</tr>
		<tr>
		<td><input type="hidden"  name="isSent" id="InputisSent" /> 
		  <input type="hidden" id="oop" value="<%=info1 %>" /></td>
		  </tr>
			</table>
			<br /><br />
			<center>

 <h2 align="center" class="button green center" data-toggle="collapse" data-target="#Gestion1" >List</h2>
  <br><br>
 
  
	<center id="Gestion1" class="collapse">
		
		<div id="affichage"  style="overflow:auto;">
        	 <%@ include file="Table.jsp" %>
        </div> 
	</center>
		
   
	


				  <script>
				  $('#InputOperateurMail').on("click", function () {
				    	 // $('#CC').val($(this).val());
				        	  
				     	  $('#CC').val($('#CC').val()+";"+$(this).val());

				        	  
				          });
				      
				      $( "#InputDate" ).datepicker({
				          changeMonth: true,
				          changeYear: true
				        });				       
   
				  //Le script Ajaaaaaaaaaaaaaaaaaax
	       $(document).ready(function() {  
	    	 
	    	   if ( $("#oop").val()!="admin")
    		   {
    	   			$("#Adminpanel").hide();
    	   			$("#Adminpanel1").hide();
    	 			$("#Adminpanel2").hide();
    	   			$("#Adminpanel3").hide();
    	   			$("#export").hide();
    	   
    		   }
	    	   
	    	   var selectionCount = 1;

	            $('#Ajouter').on("click", function () {
	            	

	                $.ajax({
	                    type: "GET",
	                    url: "controle?action=Ajouter",
	                    data: {
	                    	
	                    	Date: $("#InputDate").val(),
	                    	NomCat: $("#InputNomCat").val(),
	                    	Arret: $("#InputArrets option:selected").val(),
	                    	Ligne: $("#InputLigne").val(),	                    	
	                        Duree: $("#InputDuree").val(),

	                    },
	                    success: function (result) {
	                        $("#affichage").html(result);
	                    }
	                });
	            });
	            
	            
				
	           
	            //Modifier
	            $('#Modifier').on("click", function () {


	                $.ajax({
	                    type: "GET",
	                    url: "controle?action=Modifier",
	                    data: {
	                    	Date: $("#InputDate").val(),
	                    	NomCat: $("#InputNomCat").val(),
	                    	Arret: $("#InputArrets").val(),
	                    	Ligne: $("#InputLigne").val(),	                    	
	                        Duree: $("#InputDuree").val(),
	                     

	                    },
	                    success: function (result) {
	                        $("#affichage").html(result);
	                    }
	                });
	            });
	            //Supprimer
	            $('#Supprimer').on("click", function () {


	                $.ajax({
	                    type: "GET",
	                    url: "controle?action=Supprimer",
	                    data: {
	                    	Date: $("#InputDate").val(),
	                    	NomCat: $("#InputNomCat").val(),
	                    	Arret: $("#InputArrets").val(),
	                    	Ligne: $("#InputLigne").val(),	                    	
	                        Duree: $("#InputDuree").val(),
	                     

	                    },
	                    success: function (result) {
	                        $("#affichage").html(result);
	                    }
	                });
	            });
	            //Recherche 
	            $('#Rechercher').on("click", function () {
	            	
	            	$("#Retourner").attr('type', 'submit');
	            	$("#Rechercher").attr('type', 'hidden');

	                $.ajax({
	                    type: "GET",
	                    url: "controle?action=Rechercher",
	                    data: {
	                    	Date: $("#InputDate").val(),
	                 
	                       },
	                    success: function (result) {
	                        $("#affichage").html(result);
	                    }
	                });
	            });
	            
	            //retourner Affichage
					$('#Retourner').on("click", function () {
						$("#Retourner").attr('type', 'hidden');
		            	$("#Rechercher").attr('type', 'submit');
						        			
						                $.ajax({
						                    type: "GET",
						                    url: "controle?action=Retourner",
						                   
						                    success: function (result) {
						                        $("#affichage").html(result);
						                    }
						                });
						            });

                   //Vider les Inputs
		            $('#Vider').on("click", function () {


		            	    $("#InputDate").val("");
		                    $("#InputNomCat").val("");
		                    $("#InputArrets").val("");
		                    $("#InputLigne").val("");
		                    $("#InputDuree").val("");		                   
		            });
	            
	            //Affichage des valeurs dans les Inputs 
	            
	    
								            
	            $('#affichage').on("click", 'tbody tr', function () {
	                if ($(this).hasClass('selected')) {
	                
	                    selectionCount++;
	                    selectionCount = 1;
	                }

	                if (selectionCount == 1) {
	                	
	                	
	                    $(".selected").removeClass("selected");
	                    
	                    $(this).addClass("selected");    	
	                    
	                    var Date = $('.selected').find(".Date").text().trim();
	                    var NomCat = $('.selected').find(".NomCat").text().trim();
	                    var Arret = $('.selected').find(".Arret").text().trim();
	                    var Ligne = $('.selected').find(".Ligne").text().trim();
	                    var Duree = $('.selected').find(".Duree").text().trim();
	                    
	                    //changement du couleur
	                    $('#colonne tr').css('background','white');

	                    
	                    $("#InputDate").val(Date) ; 
	                    $("#InputNomCat").val(NomCat);
	                    $("#InputArrets").val(Arret);
	                    $("#InputLigne").val(Ligne);
	                    $("#InputDuree").val(Duree);
	                       
	                }
	            });
	            //Affichage des valeurs dans les Inputs 
	            
	    	 
             
             
             
															                var i=1;
																		      $( "#espacefournisseur" ).hide();					
																		     $( "#espaceF" ).click(function()  {					
																		     	if(i % 2 == 0)
																			{  $( "#espacefournisseur" ).hide( "slow");
																			  i=i+1;
																			}else
																			{ $( "#espacefournisseur" ).show( "slow");
																			  i=i+1;
																				}});
																		   
																		     
				            });
				  
				  
				  
				        </script>

 <!-- Date Pickeeeeeeeer! -->
 
 
    <!-- Tableau obligatoire ! C'est lui qui contiendra le calendrier ! -->
    <table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;">
      <tr>
        <td id="ds_calclass"></td>
      </tr>
    </table>
 
<script type="text/javascript" src="fichier/bootstrap.js"></script>
<script src="fichier/Site.js"></script>
</div>
</div>
</div>

</body>
</html>

